<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:p="http://www.springframework.org/schema/p"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>

    <!--*******************************配置dataSource ******************************* -->
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close" init-method="init"
          p:url="${url}"
          p:username="${jdbc.username}"
          p:password="${jdbc.password}"
          p:driverClassName="${driverClassName}"
          p:filters="${filters}"
          p:maxActive="${maxActive}"
          p:initialSize="${initialSize}"
          p:maxWait="${maxWait}"
          p:minIdle="${minIdle}"
          p:timeBetweenEvictionRunsMillis="${timeBetweenEvictionRunsMillis}"
          p:minEvictableIdleTimeMillis="${minEvictableIdleTimeMillis}"
          p:validationQuery="${validationQuery}"
          p:testWhileIdle="${testWhileIdle}"
          p:testOnBorrow="${testOnBorrow}"
          p:testOnReturn="${testOnReturn}"
          p:maxOpenPreparedStatements="${maxOpenPreparedStatements}"
          p:removeAbandoned="${removeAbandoned}"
          p:removeAbandonedTimeout="${removeAbandonedTimeout}"
          p:logAbandoned="${logAbandoned}"
    />
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation" value="classpath:mybatis-config.xml"></property>
        <property name="mapperLocations">
            <array>
                <value>classpath:mapper/*.xml</value>
            </array>
        </property>
        <property name="typeAliasesPackage" value="com.purple.*.model"/>
        <property name="plugins">
            <array>
                <bean class="com.github.pagehelper.PageHelper">
                    <!-- 这里的几个配置主要演示如何使用，如果不理解，一定要去掉下面的配置 -->
                    <property name="properties">
                        <value>
                            dialect=mysql
                            reasonable=true
                            supportMethodsArguments=true
                            params=count=countSql
                            autoRuntimeDialect=true
                        </value>
                    </property>
                </bean>
            </array>
        </property>
    </bean>
    <bean class="tk.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="${packagePath}.*.mapper"/>
    </bean>
    <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">
        <constructor-arg index="0" ref="sqlSessionFactory"/>
    </bean>
    <bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>
</beans>
